﻿using System;
using System.Web.UI;
using ThangNM_LIB.FUNC;

namespace ThangNM.UserControl
{
    public partial class CaptchaUC : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ibtnCaptcha.ImageUrl = new CaptchaProvider().CreateCaptcha();
            }
        }

        protected void ibtnCaptcha_Click(object sender, ImageClickEventArgs e)
        {
            ibtnCaptcha.ImageUrl = new CaptchaProvider().CreateCaptcha();
            ReCaptcha();
        }

        public bool CheckValidCaptcha()
        {
            CaptchaProvider captchaPro = new CaptchaProvider();
            if (!captchaPro.IsValidCode(txtCaptcha.Text))
                return false;
            else
                return true;

            return false;
        }

        public void ReCaptcha()
        {
            txtCaptcha.Text = "";
            txtCaptcha.Focus();
        }
    }
}